<template>
	<view class="earningsDetails">
		<view class="line" v-for="(item,index) in pageResult.list" :key="index" @click="jump('earnings_info', item.id)">
			<view class="top">
				<text>{{item.title}}</text>
				<text>+{{item.money}}</text>
			</view>
			<view class="bottom">
				<text>
					{{item.remark}}
				</text>
				<text>
					{{item.created_at}}
				</text>
			</view>
		</view>
		
		<view v-if="pageResult.list.length == 0" class="nocontent">
			<image src="https://hdsq.aoorange.cn/attachment/xcx/icon/noItem.png" ></image>
			<!-- <text>暂无记录～</text> -->
		</view>
	</view>
</template>

<script>
	import serve from '../../static/request.js';
	import storage from '../../static/appkey.js';
	import common from '../../static/jump.js';
	export default {
		data() {
			return {
				pageParam: {
					appkey: uni.getStorageSync('appkey'),
					'access-token': uni.getStorageSync('access-token'),
					page: 0,
					pageSize: 10
				},
				pageResult: {
					list: [],
					isEmpty: false,
					isEnd: false
				}
			}
		},
		methods: {
			getList() {
				var self = this;
				self.pageParam.page++
				serve
					.request({
						url: '/member/royalty/list',
						data: self.pageParam
					})
					.then(res => {
						if (res.data && res.data.length > 0) {
							self.pageResult.list=self.pageResult.list.concat(res.data);
						}
						self.pageResult.isEmpty = self.pageResult.list.length == 0;
						self.pageResult.isEnd = res.data.length == 0; 
					});
			},
			jump(jump_type, jump_link){
				common.jump(jump_type, jump_link);
			}
		},
		onLoad() {
			if (uni.getStorageSync('access-token') == '') {
				common.jump('login');
				return ;
			}
			this.pageParam.page=0;
			this.pageResult.list=[];
			this.getList();
		},
		onPullDownRefresh() {
			this.pageParam.page=0;
			this.pageResult.list=[];
			this.getMainInfo();
			this.loadList();
		},
		//触底加载
		onReachBottom() {
			console.log('触底'); 
			if(this.pageResult.isEnd ||this.pageResult.isEmpty){
				return
			}
			this.loadList()
		}
	}
</script>

<style scoped lang="scss">
	.earningsDetails {
		.line {
			display: flex;
			flex-direction: column;
			padding: 40rpx 30rpx 30rpx;
			border-bottom: 1rpx #F0EDE9 solid;
			justify-content: space-between;

			.top {
				display: flex;
				align-items: flex-start;
				justify-content: space-between;
				color: #444444;
				font-size: 28rpx;
				font-weight: 400;

				text:last-child {	
					color: #FFB437;
					font-size: 36rpx;
					font-weight: bold;
				}
			}

			.bottom {
				margin-top: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 24rpx;
				color: #999999;
                text{
					font-size: 24rpx;
					color: #333333;
				}


					text:last-child {
						color: #999999;
					}
				
			}
		}
		
		.nocontent{
			width: 100%;
			padding-top: 338rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			image{
				width:220rpx;
				height:220rpx;
			}
			text{
				font-size:28rpx;
				color:rgba(204,204,204,1);
			     margin-top: 30rpx;
			}
		}
	}
</style>
